﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>版本管理</title>
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <script type="text/javascript" src="../../Comm/JScript.js"></script>
    <script type="text/javascript"
            src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript"
            src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <script src="../Admin.js"></script>
    <base target="_self" />

    <script type="text/javascript">
        //页面启动函数.
        $(function () {
            $("#Msg").html("<img src=../../Img/loading.gif />&nbsp;正在加载,请稍后......");
            InitPage();
            $("#Msg").html("");
        });

        //初始化数据.
        function InitPage() {

            var flowNo = GetQueryString("FK_Flow");
            var en = new Entity("BP.WF.Flow", flowNo);

            var data = en.DoMethodReturnJSON("VerGenerVerList");

            var html = "";
            html += "<table class='table'>";
          
            html += "<tr>";
            html += "<th>版本号</th>";
            html += "<th>流程编号</th>";
            html += "<th>名称</th>";
            html += "<th>发布状态</th>";
            html += "<th>运行中数量</th>";
            html += "<th>完成数量</th>";
            html += "<th>删除</th>";
            html += "<th>操作</th>";
            html += "<th>编辑</th>";
            html += "<th>导入导出</th>";
            html += "</tr>";

            for (var i = 0; i < data.length; i++) {
                var item = data[i];

                html += "<tr>";

                var ver = item.Ver;
                if (ver == "")
                    ver = "原始版";

                html += "<td>" + ver + "</td>";
                html += "<td>" + item.No + "</td>";
                html += "<td>" + item.Name + "</td>";
                html += "<td>" + item.IsRel + "</td>";
                html += "<td>" + item.NumOfRuning + "</td>";
                html += "<td>" + item.NumOfOK + "</td>";

                if (item.IsRel == 0) {
                    html += "<td><a href=\"javascript:Del('"
                        + item.No
                        + "')\"><img src='../../Img/Btn/Delete.gif' /></a></td>";
                    html += "<td><a href=\"javascript:SetCurrentVer('" + item.No
                        + "')\">设置主版本</a></td>";
                } else {
                    html += "<td>--</td>";
                    html += "<td>主版本</td>";
                }

                html += "<td><a class='cc-btn-tab' href='javaScript:void(0)' onclick='changeOrOpenTab(\""
                    + item.Name + "\",\"" + item.No + "\")'>编辑</a></td>";

                html += "<td><a class='cc-btn-tab' href='Imp.htm?FK_Flow=" + item.No + "'>导入</a>&nbsp&nbsp<a class='cc-btn-tab' href='Exp.htm?FK_Flow=" + item.No + "'>导出</a></td>";

                html += "</tr>";
            }
            html += "</table>";
            $("#docs").html(html);
        }


        //已知URL,在右侧打开页面
        function OpenWindowRight(url, title) {
            if (top.layui.index) {
                top.layui.index.openTabsPage(url, title)
            } else {
                window.open(url)
            }
        }


        function changeOrOpenTab(flowName, flowNo) {
            //"&UserNo=" + WebUser.No + "&Token=" + webUser.Token + "&Flow_V=1", node.iconCls
            var webUser = new WebUser();
            var url = basePath + "/WF/Admin/CCBPMDesigner/Designer.htm?FK_Flow=" + flowNo;

            url += "&UserNo=" + webUser.No + "&Token=" + webUser.Token + "&Flow_V=1&OrgNo=" + webUser.OrgNo;
            if (top.layui.index) {
                url = "../FlowDesigner/Designer.htm?FK_Flow=" + flowNo;

                url += "&UserNo=" + webUser.No + "&Token=" + webUser.Token + "&Flow_V=1&OrgNo=" + webUser.OrgNo;
                top.layui.index.openTabsPage(url, flowNo + "." + flowName);
            } else {
                if (typeof window.parent.parent.addTab != "undefined")
                    window.parent.parent.addTab(flowNo, flowNo + "." + flowName, url,
                        "icon-flow1");
                else
                    window.parent.parent.location.href = url;

            }
            

        }

        function Del(no) {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var en = new Entity("BP.WF.Flow", no);
            var data = en.DoMethodReturnString("DoDelete");

            alert("删除成功");
            Reload();
        }
        //创建新版本.
        function NewVer() {

            if (window.confirm('您确定要创建新版本吗？') == false)
                return;

            $("#Msg")
                .html(
                    "<br><br><br><br><center ><img src='../../Img/loading.gif' /><font color=green>正在创建,请稍后......</blue><br><br><br><br></center>");

            var flowNo = GetQueryString("FK_Flow");
            var en = new Entity("BP.WF.Flow", flowNo);
            var data = en.DoMethodReturnString("VerCreateNew");

            $("#Msg")
                .html(
                    "<br><br><br><br><center ><img src='../../Img/loading.gif' /><font color=green>版本创建成功，正在执行流程检查。。。</blue><br><br><br><br></center>");

            en = new Entity("BP.WF.Flow", data);
            en.DoMethodReturnString("DoCheck");

            //alert(data);
            // $("#Msg").html("<br><br><br><br><center ><img src='../../Img/loading.gif' /><font color=green>正在创建,请稍后......</blue><br><br><br><br></center>");

            Reload();
        }
        function SetCurrentVer(no) {

            if (window.confirm('您确定要设置为当前版本？') == false)
                return;

            $("#Msg")
                .html(
                    "<br><br><br><br><center ><img src='../../Img/loading.gif' /><font color=green>正在执行设置，请稍后。。</blue><br><br><br><br></center>");

            var en = new Entity("BP.WF.Flow", no);
            var data = en.DoMethodReturnString("VerSetCurrentVer");
            en.DoMethodReturnString("DoCheck");
            Reload();
        }

        function More() {

            var url = "https://blog.csdn.net/ccflow/article/details/100854967";
            WinOpen(url);
        }

    </script>
    <style type="text/css">
        caption {
            text-align: left;
            font-family: 'Microsoft YaHei';
            font-weight: bolder;
            border-bottom: none;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <div class="container-full">

        <div id="titleH4" class="attrnode-bar-header">
            <span class="pull-right">
                <button id="Btn_New" class="cc-btn-tab btn-new" onclick="NewVer();">新建版本</button>
                <button id="Btn_Help" class="cc-btn-tab btn-hlep" onclick="More();">帮助?</button>
            </span>
            <strong>版本管理 </strong>
        </div>
        <div id="docs"></div>

        <div style="position:relative;" id="Msg"></div>
    </div>
</body>
</html>
